// import {Rentalable} from '@/store/modules/types/Order'
import {AssetStock} from '@/store/modules/types/AssetStock'
import {Asset} from '@/store/modules/types/Asset'
import {Rentalable, WithId} from '@/store/modules/types/Bundle'

export enum OrderItemType {
  Asset = 'App\\Models\\Asset',
  AssetStock = 'App\\Models\\AssetStock',
  ExtraFee = 'App\\Models\\Order\\OrderExtraFee'
}

export interface Order {
  id?: number;
  customer_id?: number;
  order_number?: string;
  description?: string;
  expected_rental_out_date?: Date;
  expected_return_date?: Date;
  expected_ship_date?: Date;
  real_rental_out_date?: Date;
  real_return_date?: Date;
  real_ship_date?: Date;
  status_id?: number;
  payment_method_id?: number;
  is_paid?: boolean;
  paid_at?: Date;
  net_amount?: string;
  paid_amount?: string;
  payable_amount?: string;
  ship_address?: string;
  identification_number?: string;
  location?: string;
  discount?: string;
  created_by?: AssignedTo;
  assigned_to?: AssignedTo;
  created_at?: string;
  updated_at?: Date;
  deleted_at?: null;
  customer?: Customer;
  status?: OrderStatus;
  payment_method?: PaymentMethod;
  items?: OrderItem[],
  bundles?: OrderBundle[]
}

export interface AssignedTo {
  id?: number;
  name?: string;
  email?: string;
  email_verified_at?: string;
  created_at?: string;
  updated_at?: Date;
  deleted_at?: null;
}

export interface Customer {
  id?: number;
  name?: string;
  address?: string;
  tel?: string;
  email?: string;
  contact_name?: string;
  contact_tel?: string;
  contact_email?: string;
  identify_code?: string;
  created_at?: Date;
  updated_at?: Date;
  deleted_at?: Date;
}

export interface OrderBundle extends WithId{
  name?: string;
  bundle_id: number;
  order_id?: number;
  amount: number;
  rental_out_at?: Date | null;
  return_at?: Date | null;
  items?: OrderBundleItem[];
  created_at?: Date;
  updated_at?: Date;
  deleted_at?: Date;
}

export interface OrderBundleItem extends WithId{
  order_bundle_id: number;
  name: string;
  rentalable_id: number;
  rentalable_type: string;
  quantity: number;
  unit_price: number;
  amount: number;
  rental_out_at?: Date;
  return_at?:Date;
  created_at?: Date;
  updated_at?: Date;
  deleted_at?: Date;
}

export interface OrderItem extends WithId {
  order_id?: string;
  name?: string;
  rentalable_id?: number | string;
  rentalable_type?: string;
  quantity?: number | string;
  unit_price?: number;
  amount?: number;
  rental_out_at?: Date | null;
  return_at?: Date | null;
  created_at?: Date;
  updated_at?: Date;
  rentalable?: Asset | AssetStock | OrderExtraFee
}

export interface OrderExtraFee extends Rentalable{
  quantity?: number
  unit_price?: number
}

export interface KeyValueLabel {
  id?: number;
  name?: string;
  label?: string;
}

export interface SampleKeyValue {
  key?: string;
  lbl?: string;
}

export interface PaymentMethod {
  id?: number;
  name?: string;
  label?: string;
}

export interface OrderStatus {
  id?: number;
  name?: string;
  label?: string;
}

export const OrderLang: { [key: string]: string } = {
  customer_id: '客户ID',
  order_number: '订单编号',
  description: '描述',
  expected_rental_out_date: '预期租借开始日期',
  expected_return_date: '预期归还日期',
  expected_ship_date: '预期物流送出时间',
  real_rental_out_date: '实际租借开始日期',
  real_return_date: '实际归还日期',
  real_ship_date: '实际物流送出时间',
  status_id: '状态',
  payment_method_id: '支付渠道',
  is_paid: '已完成全部付费',
  paid_at: '支付日期',
  net_amount: '应付金额',
  paid_amount: '已支付金额',
  payable_amount: '待支付金额',
  ship_address: '送货地址',
  identification_number: '运单号',
  location: '仓库地址',
  discount: '折扣',
  created_by: '创建者',
  assigned_to: '经办人',
  created_at: '创建日期',
  updated_at: '更新日期',
  deleted_at: '删除日期',
  customer: '客户',
  status: '状态',
  payment_method: '支付渠道'
}

export const OrderItemDataTableDef = {
  headers: [
    {
      text: '物品名称',
      align: 'right',
      value: 'name',

    },
    {
      text: '单价',
      align: 'right',
      value: 'unit_price',
    },
    {
      text: '出库日期',
      value: 'rental_out_at',
    },
    {
      text: '归还日期',
      value: 'return_at',
    },
    {
      text: '数量',
      align: 'right',
      value: 'quantity',
    },
    {
      text: '价格',
      align: 'right',
      value: 'amount',
    },
  ]
}

export const OrderBundleItemsDataTableDef = {
  headers: [
    {
      text: '物品名称',
      align: 'right',
      value: 'name',

    },
    {
      text: '数量',
      align: 'right',
      value: 'quantity',
    },
    {
      text: '资产类型',
      align: 'right',
      value: 'assetType',
    },
  ]
}
